load(
    "@rules_rust//rust:defs.bzl",
    "rust_doc",
    "rust_doc_test",
    "rust_library",
    "rust_test",
    "rust_test_suite",
)

rust_library(
    name = "nativelink-service",
    srcs = [
        "src/ac_server.rs",
        "src/bep_server.rs",
        "src/bytestream_server.rs",
        "src/capabilities_server.rs",
        "src/cas_server.rs",
        "src/execution_server.rs",
        "src/fetch_server.rs",
        "src/health_server.rs",
        "src/lib.rs",
        "src/push_server.rs",
        "src/remote_asset_proto.rs",
        "src/worker_api_server.rs",
    ],
    visibility = ["//visibility:public"],
    deps = [
        "//nativelink-config",
        "//nativelink-error",
        "//nativelink-proto",
        "//nativelink-scheduler",
        "//nativelink-store",
        "//nativelink-util",
        "@crates//:axum",
        "@crates//:bytes",
        "@crates//:futures",
        "@crates//:http-body-util",
        "@crates//:hyper-1.7.0",
        "@crates//:opentelemetry",
        "@crates//:opentelemetry-semantic-conventions",
        "@crates//:parking_lot",
        "@crates//:prost",
        "@crates//:prost-types",
        "@crates//:rand",
        "@crates//:serde_json5",
        "@crates//:sha2",
        "@crates//:tokio",
        "@crates//:tonic",
        "@crates//:tower",
        "@crates//:tracing",
        "@crates//:uuid",
    ],
)

rust_test_suite(
    name = "integration",
    timeout = "short",
    srcs = [
        "tests/ac_server_test.rs",
        "tests/bep_server_test.rs",
        "tests/bytestream_server_test.rs",
        "tests/cas_server_test.rs",
        "tests/execution_server_test.rs",
        "tests/fetch_server_test.rs",
        "tests/health_server_test.rs",
        "tests/push_server_test.rs",
        "tests/worker_api_server_test.rs",
    ],
    proc_macro_deps = [
        "//nativelink-macro",
        "@crates//:async-trait",
    ],
    deps = [
        "//nativelink-config",
        "//nativelink-error",
        "//nativelink-metric",
        "//nativelink-proto",
        "//nativelink-scheduler",
        "//nativelink-service",
        "//nativelink-store",
        "//nativelink-util",
        "@crates//:async-lock",
        "@crates//:axum",
        "@crates//:bytes",
        "@crates//:futures",
        "@crates//:hex",
        "@crates//:http-body-util",
        "@crates//:hyper-1.7.0",
        "@crates//:hyper-util",
        "@crates//:pretty_assertions",
        "@crates//:prost",
        "@crates//:prost-types",
        "@crates//:serde_json",
        "@crates//:sha2",
        "@crates//:tokio",
        "@crates//:tokio-stream",
        "@crates//:tonic",
        "@crates//:tower",
        "@crates//:tracing",
        "@crates//:tracing-test",
    ],
)

rust_test(
    name = "unit_test",
    timeout = "short",
    crate = ":nativelink-service",
    proc_macro_deps = [
        "//nativelink-macro",
        "@crates//:async-trait",
    ],
    deps = [
        "//nativelink-metric",
        "@crates//:async-lock",
        "@crates//:hyper",
        "@crates//:hyper-util",
        "@crates//:pretty_assertions",
        "@crates//:prost-types",
    ],
)

rust_doc(
    name = "docs",
    crate = ":nativelink-service",
    visibility = ["//visibility:public"],
)

rust_doc_test(
    name = "doc_test",
    timeout = "short",
    crate = ":nativelink-service",
)
